package org.argeproje.resim.proc.data;


public final class ConverterUT {
	public static float[] get1DFloatArray(double[] array) {
		float[] result = new float[array.length];
		for (int i = 0; i < result.length; i++) {
			result[i] = (float) array[i];
		}
		return result;
	}
	public static float[] get1DFloatArray(float[][] array) {
		int nRow = array.length;
		int nCol = array[0].length;
		float[] result = new float[nRow * nCol];
		for (int i = 0; i < nRow; i++) {
			for (int j = 0; j < nCol; j++) {
				result[i*nCol + j] = array[i][j];
			}
		}
		return result;
	}
	public static float[][] get2DFloatArray(double[][] array) {
		float[][] result = new float[array.length][array[0].length];
		for (int i = 0; i < result.length; i++) {
			for (int j = 0; j < result[0].length; j++) {
				result[i][j] = (float) array[i][j];
			}
		}
		return result;
	}

	public static float[][] get2DFloatArray(int[][] array) {
		float[][] result = new float[array.length][array[0].length];
		for (int i = 0; i < result.length; i++) {
			for (int j = 0; j < result[0].length; j++) {
				result[i][j] = (float) array[i][j];
			}
		}
		return result;
	}

	public static int[][] get2DIntArray(float[][] array) {
		int[][] result = new int[array.length][array[0].length];
		for (int i = 0; i < result.length; i++) {
			for (int j = 0; j < result[0].length; j++) {
				result[i][j] = (int) array[i][j];
			}
		}
		return result;
	}

	public static double[][] get2DDoubleArray(float[][] array) {
		double[][] result = new double[array.length][array[0].length];
		for (int i = 0; i < result.length; i++) {
			for (int j = 0; j < result[0].length; j++) {
				result[i][j] = (double) array[i][j];
			}
		}
		return result;
	}

	public static double[] get1DDoubleArray(double value, int length) {
		double[] array = new double[length];
		for (int i = 0; i < array.length; i++) {
			array[i] = value;
		}
		return array;
	}

	public static int[] get1DIntArray(int value, int length) {
		int[] array = new int[length];
		for (int i = 0; i < array.length; i++) {
			array[i] = value;
		}
		return array;
	}

	public static float[][] get2DFloatArray(float[] array, int nRows) {
		float[][] result = new float[nRows][array.length];
		for (int i = 0; i < array.length; i++) {
			result[i] = (float[]) array.clone();
		}
		return result;
	}
}
